<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>对象继承</title>
	</head>
	<body>
		<script>
			// ES5的类继承
			// 手机
			// function Phone(brand,price) {
			// 	console.log('====>>>>>>'+this);
			// 	this.brand = brand;
			// 	this.price = price;
			// }
			
			// Phone.prototype.call = function() {
			// 	console.log('call phone......');
			// }
			
			// function SmartPhone(brand,price,color,size) {
			// 	Phone(this,brand,price);
			// 	this.color = color;
			// 	this.size = size;
			// }
			// // 设置子级构造函数的原型
			// SmartPhone.prototype = new Phone;
			// SmartPhone.prototype.constructor = SmartPhone;
			
			// // 声明子类的方法
			// SmartPhone.prototype.photo = function() {
			// 	console.log('can take a picture');
			// }
			// SmartPhone.prototype.playGame = function() {
			// 	console.log('can play game');
			// }
			// const cz = new SmartPhone('锤子',1999,'黑色','7寸');
			// console.log(cz);
			// ES6的继承
			class Phone {
				constructor(brand,price) {
					console.log('====>>>>>>'+this);
					this.brand = brand;
					this.price = price;
				}
				
				call() {
					console.log('我可以打电话...');
				}
			}
			class SmartPhone extends Phone{
				constructor(brand,price,color,size) {
					super(brand,price);
					this.color = color;
					this.size = size;
				}
				photo() {
					console.log('take a pictrue');
				}
				playGame() {
					console.log('play game...');
				}
				call() {
					console.log('call video talk message');
				}
			}
			const xm = new SmartPhone('xiaomi',699,'black','7');
			console.log(xm);
			xm.call();
			xm.photo();
			xm.playGame();
		</script>
	</body>
</html>